package com.demo.controller;

import com.demo.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;

import javax.annotation.Resource;

/**
 * @program: spring-demo2
 * @author: JCM
 * @create: 2023-02-23 12:21
 * @description:
 **/

@Controller
public class StudentController {

    //1. 使用属性注入的方法获取  Bean
    //@Autowired
//    @Resource
//    private StudentService studentService;

    // 2. set 注入
//    private StudentService studentService;
//
//    @Autowired
//    public void setStudentService(StudentService studentService) {
//        this.studentService = studentService;
//    }

    // 3. 构造方法注入
//    private final StudentService studentService;
//
//    @Autowired  //  只有一个构造方法时，可以不加
//    public StudentController(StudentService studentService) {
//        this.studentService = studentService;
//    }
//
//    public void sayHi() {
//        studentService.sayHi();
//    }

}
